<?php
define('APPHOME','1.00');

/************************************************************************/
/* FrameWork  test preview                                              */
/* ==================================================================== */
/*                                                                      */
/* This program is free software. You can redistribute it and/or modify */
/* it under the terms of the GNU General Public License as published by */
/* the Free Software Foundation; either version 2 of the License.       */
/************************************************************************/


/* Home Page */

 // carica libemoticons e libBBcode se sono presenti
loadlib("libBBcode");
loadlib("libEmoticons");


/* solo gli amministratori registrati possono cambiare il testo dell'home page */
if ((defined('LIBGROUP') && group_getusergroup("webmaster",user_getuser())) || admin_isadmin()){
    $save=$_POST['save'];
    $datas=stripslashes($_POST['editor']);
    if (!file_exists("extras/FCKeditor/fckeditor.php")){
	if (defined('LIBBBCODE'))$datas=bb2html($datas);
	if (defined('LIBEMOTICONS'))$datas=emoticons2html($datas);
    }

    if($save!=""){
        admin_writelog("modify home");
	$fp=fopen($save,"w");
	fwrite($fp,$datas);
	fclose($fp);
    }
}

/*******************************************************************************/

/*crea la pagina di default ****************************************************/

// non sono dati riservati e vengono scritti fuori da sb nella cartella con nome $apptitle
if (!file_exists("datas/$path/$apptitle"))mkdir("datas/$path/$apptitle",0755);
if (!file_exists("datas/$path/$apptitle/images"))mkdir("datas/$path/$apptitle/images",0755);
if (!file_exists("datas/$path/$apptitle/images/motd.gif")){
  copy("$path/$appname/images/motd.gif","datas/$path/$apptitle/images/motd.gif");
}

if (!file_exists("datas/$path/$apptitle/pagina")){
        $fp=fopen("datas/$path/$apptitle/pagina","w");
      //Scrive il file attenzione i path devono essere assoluti per compatibilita' con FCKeditor
      fwrite($fp,str_replace("_image_path",base_path()."datas/$path/$apptitle", @join(@file("$path/$appname/default"))));
	fclose($fp);
 }
/*******************************************************************************/

?>

<?php //structure_openBlock("table appl","description",""); ?>

<p>
<style>
h3
{
	margin: 0;
	font-size: 14px;
}

</style>

<?php echo join(file("datas/$path/$apptitle/pagina")); ?>
</p>

<?php // edit_link($path,$apptitle); ?>
<?php // edit_code_link("$path/$appname/application.inc"); ?>
<?php // print_html_app($appname); ?>

<?php toolbar($path,$apptitle,$filename,$appname); ?>

<?php //structure_closeBlock(); ?>
